<?php

namespace app\model\product\sku;

use app\model\distributor\Distributor;
use app\model\product\product\StoreProduct;
use crmeb\basic\BaseModel;
use crmeb\traits\ModelTrait;

class StoreProductStockRelation extends BaseModel
{
    use  ModelTrait;

    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 模型名称
     * @var string
     */
    protected $name = 'store_product_stock_relation';

    public function product()
    {
        return $this->belongsTo(StoreProduct::class, 'product_id', 'id');
    }

    public function distributor()
    {
        return $this->belongsTo(Distributor::class, 'distributor_id', 'id');
    }

    public function attrValue()
    {
        return $this->belongsTo(StoreProductAttrValue::class, 'product_attr_value_unique', 'unique');
    }
}